package com.start.workflow.admin;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.start.common.api.Result;
import com.start.common.dataRule.DataQueryConstructor;
import com.start.core.annotations.RegisterPermission;
import com.start.core.annotations.StartLog;
import com.start.workflow.core.manage.StartActInstManage;
import com.start.workflow.core.service.StartActBusinessService;
import com.start.workflow.vo.StartActBusinessVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@Tag(name = "流程业务管理")
@RestController
@RequestMapping("/start/actBusiness")
public class StartActBusinessController {
    private static final String LOG_TITLE = "流程业务管理" ;
    @Autowired
    private StartActBusinessService startActBusinessService;

    @Autowired
    private StartActInstManage startActInstManage;


    @GetMapping("/pageBusiness")
    @StartLog(value = LOG_TITLE, action = "查询")
    @PreAuthorize("@pas.hasPermission('start:act:business:info')")
    @RegisterPermission(value = "start:act:business:info", name = "查询流程业务")
    public Result<?> pageBusiness(Page<StartActBusinessVo> page) {
        QueryWrapper<StartActBusinessVo> queryWrapper = DataQueryConstructor.createEntity(StartActBusinessVo.class);
        return Result.ok(startActBusinessService.pageBusiness(page, queryWrapper));
    }

    @DeleteMapping("/deleteById/{id}")
    @StartLog(value = LOG_TITLE, action = "删除")
    @PreAuthorize("@pas.hasPermission('start:act:business:del')")
    @RegisterPermission(value = "start:act:business:del", name = "删除流程业务")
    public Result<?> deleteById(@PathVariable("id") String id) {
        startActInstManage.deleteActIns(id);
        return Result.ok();
    }


}
